#include <bits/stdc++.h>
using namespace std;
const int N = 55, mod = 1e9 + 7;
int n, m;
char s[N];
int f[N][N], ne[N];
int main() {
  cin >> n >> s + 1;
  m = strlen(s + 1);
  for (int i = 2, j = 0; i <= m; ++i) {
    while (j && s[i] != s[j + 1]) j = ne[j];
    if (s[i] == s[j + 1]) ++j;
    ne[i] = j;
  }
  f[0][0] = 1;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      for (char ch = 'a'; ch <= 'z'; ++ch) {
        int ptr = j;
        while (ptr && s[ptr + 1] != ch) ptr = ne[ptr];
        if (s[ptr + 1] == ch) ++ptr;
        f[i + 1][ptr] = (f[i + 1][ptr] + f[i][j]) % mod;
      }
    }
  }
  int res = 0;
  for (int j = 0; j < m; ++j) res = (res + f[n][j]) % mod;
  cout << res << endl;
}
